﻿using ChurchDiary.DAL.Contract;
using ChurchDiary.DAL.Methods;
using ChurchDiary.TableEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChurchDiary.BLL
{
    public class BLL_Shared
    {
        IDALShared country = new DAL_Shared();
        #region Country
        public List<EntityCountry> GetCountryList()
        {
            return country.GetCountryDetails();
        }
        public EntityCountry GetCountry(Guid CountryId)
        {
            return country.GetCountry(CountryId);
        }
        public string GetCountryList(List<EntityCountry> Countries)
        {
            StringBuilder sbCountries = new StringBuilder();
            int i = 1;
            foreach (EntityCountry lst in Countries)
            {
                sbCountries.Append("<tr class=\"even pointer\">");
                sbCountries.Append("<td class=\"\">" + i + "</td>");
                sbCountries.Append("<td class=\" \">" + lst.CountryName + "</td>");
                sbCountries.Append("<td class=\" \">");
                sbCountries.Append("<ul class=\"actionicons\">");
                sbCountries.Append("<li><a data-id=" + lst.CountryId + " data-toggle=\"tooltip\" class=\"del confirmbox\" data-placement=\"bottom\" title=\"\" data-original-title=\"Delete\"><i class=\"fa fa-trash\"></i></a></li>");
                sbCountries.Append("<li><a data-id=" + lst.CountryId + " data-toggle=\"tooltip\" class=\"edit\" data-placement=\"bottom\" title=\"\" data-original-title=\"Edit\"><i class=\"fa fa-pencil\"></i></a></li>");
                sbCountries.Append("</ul>");
                sbCountries.Append("</td>");
                sbCountries.Append("</tr>");
                i += 1;
            }
            return sbCountries.ToString();
        }        
        public string InsertCountryDetails(EntityCountry Country)
        {
            return country.InsertCountryDetails(Country);
        }
        public string UpdateCountryDetails(EntityCountry Country)
        {
            return country.UpdateCountryDetails(Country);
        }
        public string DeleteCountryDetails(Guid CountryId)
        {
            return country.DeleteCountryDetails(CountryId);
        }
        #endregion
        #region State
        public List<EntityStates> GetStateList()
        {
            return country.GetStateDetails();
        }
        public EntityStates GetState(Guid StateId)
        {
            return country.GetState(StateId);
        }
        public string GetStateList(List<EntityStates> Countries)
        {
            StringBuilder sbStates = new StringBuilder();
            int i = 1;
            foreach (EntityStates lst in Countries)
            {                
                sbStates.Append("<tr class=\"even pointer\">");
                sbStates.Append("<td class=\"\">" + i + "</td>");
                sbStates.Append("<td class=\"\">" + lst.Country.CountryName + "</td>");
                sbStates.Append("<td class=\" \">" + lst.StateName + "</td>");
                sbStates.Append("<td class=\" \">");
                sbStates.Append("<ul class=\"actionicons\">");
                sbStates.Append("<li><a data-id=" + lst.StateId + " data-toggle=\"tooltip\" class=\"del confirmbox\" data-placement=\"bottom\" title=\"\" data-original-title=\"Delete\"><i class=\"fa fa-trash\"></i></a></li>");
                sbStates.Append("<li><a data-id=" + lst.StateId + " data-toggle=\"tooltip\" class=\"edit\" data-placement=\"bottom\" title=\"\" data-original-title=\"Edit\"><i class=\"fa fa-pencil\"></i></a></li>");
                sbStates.Append("</ul>");
                sbStates.Append("</td>");
                sbStates.Append("</tr>");
                i += 1;
            }
            return sbStates.ToString();
        }
        public string InsertStateDetails(EntityStates State)
        {
            return country.InsertStateDetails(State);
        }
        public string UpdateStateDetails(EntityStates State)
        {
            return country.UpdateStateDetails(State);
        }
        public string DeleteStateDetails(Guid StateId)
        {
            return country.DeleteStateDetails(StateId);
        }
        #endregion
        #region Greade Settings
        public string AddGrageSettings(EntityGrade Grade)
        {
            return country.InsertGrageSettings(Grade);
        }
        public string UpdateGrageSettings(EntityGrade Grade)
        {
            return country.UpdateGrageSettings(Grade);
        }
        public string DeleteSettings(Guid GradeId)
        {
            return country.DeleteSettings(GradeId);
        }
        public List<EntityGrade> GetGrageSettings()
        {
            return country.GetGrageSettings();
        }
        public EntityGrade GetGrageSetting(Guid GradeId)
        {
            return country.GetGrageSetting(GradeId);
        }
        public string GetGraeList(List<EntityGrade> Grade)
        {
            StringBuilder sbGrade = new StringBuilder();
            int i = 1;
            foreach (EntityGrade lst in Grade)
            {
                sbGrade.Append("<tr class=\"even pointer\">");
                sbGrade.Append("<td class=\"\">" + i + "</td>");
                sbGrade.Append("<td class=\"\">" + lst.GradeName + "</td>");
                sbGrade.Append("<td class=\" \">" + lst.GradeRangeStart + "-" + lst.GradeRangeEnd + "</td>");
                sbGrade.Append("<td class=\" \">" + lst.AmountToPay + "</td>");
                sbGrade.Append("<td class=\" \">" + lst.AmountToSave + "</td>");
                sbGrade.Append("<td class=\" \">");
                sbGrade.Append("<ul class=\"actionicons\">");
                sbGrade.Append("<li><a data-id=" + lst.GradeId + " data-toggle=\"tooltip\" class=\"del confirmbox\" data-placement=\"bottom\" title=\"\" data-original-title=\"Delete\"><i class=\"fa fa-trash\"></i></a></li>");
                sbGrade.Append("<li><a data-id=" + lst.GradeId + " data-toggle=\"tooltip\" class=\"edit\" data-placement=\"bottom\" title=\"\" data-original-title=\"Edit\"><i class=\"fa fa-pencil\"></i></a></li>");
                sbGrade.Append("</ul>");
                sbGrade.Append("</td>");
                sbGrade.Append("</tr>");
                i += 1;
            }
            return sbGrade.ToString();
        }
        #endregion
        #region Jobtitle
        public string AddJobtitle(EntityJobtitle Jobtitle)
        {
            return country.InsertJobTitle(Jobtitle);
        }
        public string UpdateJobtitle(EntityJobtitle Jobtitle)
        {
            return country.UpdateJobTitle(Jobtitle);
        }
        public string DeleteJobtitle(Guid JobtitleId)
        {
            return country.DeleteJobTitle(JobtitleId);
        }
        public List<EntityJobtitle> GetJobTitles(int PageNo, string SearchKey, string Sort, string SortMode, int PerPage)
        {
            return country.GetJobTitles(PageNo, SearchKey, Sort, SortMode, PerPage);
        }
        public EntityJobtitle GetJobtitle(Guid JobtitleId)
        {
            return country.GetJobTitle(JobtitleId);
        }
        public List<EntityJobtitle> GetJobTitles(int OrganizationId)
        {
            return country.GetJobTitles(OrganizationId);
        }
        public string GetJobTitleDropDown(List<EntityJobtitle> Jobtitle)
        {
            StringBuilder sbJobtitle = new StringBuilder();
            sbJobtitle.Append("<option value=\"\">Please Select</option>");
            foreach (EntityJobtitle lst in Jobtitle)
            {
                sbJobtitle.Append("<option value=" + lst.JobTitleId + ">" + lst.JobTitleName + "</option>");
            }
            return sbJobtitle.ToString();
        }
        public string GetJobTitlelist(List<EntityJobtitle> Jobtitle)
        {
            StringBuilder sbGrade = new StringBuilder();
            int i = 1;
            foreach (EntityJobtitle lst in Jobtitle)
            {
                sbGrade.Append("<tr class=\"even pointer\">");
                sbGrade.Append("<td class=\"\">" + i + "</td>");
                sbGrade.Append("<td class=\"\">" + lst.JobTitleName + "</td>");
                sbGrade.Append("<td class=\" \">" + lst.OrganizationName + "</td>");
                sbGrade.Append("<td class=\" \">");
                sbGrade.Append("<ul class=\"actionicons\">");
                sbGrade.Append("<li><a data-id=" + lst.JobTitleId + " data-toggle=\"tooltip\" class=\"del confirmbox\" data-placement=\"bottom\" title=\"\" data-original-title=\"Delete\"><i class=\"fa fa-trash\"></i></a></li>");
                sbGrade.Append("<li><a data-id=" + lst.JobTitleId + " data-toggle=\"tooltip\" class=\"edit\" data-placement=\"bottom\" title=\"\" data-original-title=\"Edit\"><i class=\"fa fa-pencil\"></i></a></li>");
                sbGrade.Append("</ul>");
                sbGrade.Append("</td>");
                sbGrade.Append("</tr>");
                i += 1;
            }
            return sbGrade.ToString();
        }
        public List<Departments> GetOrganizationPartition()
        {
            IOrganization Org = new DAL_Organization();
            return Org.GetDepartMents();
        }
        #endregion
        #region Language
        public List<EntityLanguage> GetLanguages()
        {
            IDALShared Language = new DAL_Shared();
            return Language.GetLanguages();
        }
        public List<EntityLanguage> GetLanguages(int PageNo, string SearchKey, string Sort, string SortMode, int PerPage)
        {
            IDALShared Language = new DAL_Shared();
            return Language.GetLanguages(PageNo, SearchKey, Sort, SortMode, PerPage);
        }
        public EntityLanguage GetLanguage(Guid LanguageId)
        {
            IDALShared Language = new DAL_Shared();
            return Language.GetLanguage(LanguageId);
        }
        public string InsertLanguage(EntityLanguage Language)
        {
            IDALShared Lang = new DAL_Shared();
            return Lang.InsertLanguage(Language);
        }
        public string UpdateLanguage(EntityLanguage Language)
        {
            IDALShared Lang = new DAL_Shared();
            return Lang.UpdateLanguage(Language);
        }
        public string DeleteLanguage(Guid LanguageId)
        {
            IDALShared Language = new DAL_Shared();
            return Language.DeleteLanguage(LanguageId);
        }
        #endregion
        #region
        public string InsertComments(EntityComments Comments)
        {
           return country.insertComments(Comments);
        }
        #endregion
        
        #region relationship
        public List<EntityRelationShip> GetRelationShip()
        {
           return country.GetRelationShip();
        }
        
        public List<EntityRelationShip> GetUnMarriedRelationShip()
        {
            IDALShared RL = new DAL_Shared();
            return RL.GetUnMarriedRelationShip();
        }
        public EntityRelationShip GetRelationShipByID(Guid RelationshipId)
        {
            IDALShared RL = new DAL_Shared();
            return RL.GetRelationShipByID(RelationshipId);
        }
        public List<EntityRelationShip> GetAllRelationShips(int PageNo, string SearchKey, string Sort, string SortMode)
        {
            IDALShared RL = new DAL_Shared();
            return RL.GetAllRelationShips(PageNo, SearchKey, Sort, SortMode);
        }
        public string InsertRelationShip(EntityRelationShip RelationShip)
        {
            IDALShared RL = new DAL_Shared();
            return RL.InsertRelationShip(RelationShip);
        }
        public string UpdateRelationShip(EntityRelationShip RelationShip)
        {
            IDALShared RL = new DAL_Shared();
            return RL.UpdateRelationShip(RelationShip);
        }
        public string DeleteRelationShip(Guid RelationShipId)
        {
            IDALShared RL = new DAL_Shared();
            return RL.DeleteRelationShip(RelationShipId);
        }
        #endregion
        #region DefaultConfig
        public string InsertDefaultConfig(EntityDefaultConfig DefaultConfig)
        {
            return country.InsertDefaultConfig(DefaultConfig);
        }
        public string UpdateDefaultConfig(EntityDefaultConfig DefaultConfig)
        {
            return country.UpdateDefaultConfig(DefaultConfig);
        }
        public string DeleteDefaultConfig(Guid KeyId)
        {
            return country.DeleteDefaultConfig(KeyId);
        }
        public List<EntityDefaultConfig> GetDefaultConfig()
        {
            return country.GetDefaultConfig();
        }
        public EntityDefaultConfig GetDefaultConfig(Guid KeyId)
        {
            return country.GetDefaultConfig(KeyId);
        }
        #endregion
        #region Dateformat
        public List<EntityDateFormat> GetDateformat()
        {
            return country.GetDateformat();
        }
        #endregion
    }
}
